package listalgorithm

type Node struct {
	next *Node
	data interface{}
}

func checkIflistHasLoop(alist *Node) bool {

	if alist != nil {
		var p1 *Node = alist
		var p2 *Node = alist

		for p2 != nil && p2.next != nil {
			p2 = p2.next.next
			p1 = p1.next

			if p2 == p1 {
				return true
			}
		}
	}
	return false
}
